/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ia_multiagent1;

/**
 *
 * @author Harakan
 */
public class Case {
    private int ressource; //peut prendre la valeur 0,1,2,3
                           // 0 signifie "absence de ressource"  
    
   // private int attraction;
    private int x;
    private int y;
    private int QtePheromones;
    private int lifeRessource;

    public void setQtePheromones(int QtePheromones) {
        this.QtePheromones = QtePheromones;
    }
    
    public int getQtePheromones() {
        return this.QtePheromones;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }
    
  //  public int getAttraction() {
 //       return attraction;
 //   }

 //   public void setAttraction(int attraction) {
 //       this.attraction = attraction;
 //   }

    public int getLifeRessource() {
        return lifeRessource;
    }

    public void setLifeRessource(int lifeRessource) {
        this.lifeRessource = lifeRessource;
    }
    
    
    public Case(int x, int y){
        this.ressource = 0;
        this.x = x;
        this.y = y;
        this.lifeRessource = 0;
    }
    
    /** Mise a jour des ressources de la case.
     * 
     * @return Le type de ressource retire le cas echeant.
     */
    public int majRessource(){
        if (ressource != 0){
            this.lifeRessource--;
            if (this.lifeRessource == 0){
                int temp = this.ressource;
                this.ressource = 0;
                return temp;
            }
        }
        return 0;
    }
    

    public void print() {
        System.out.print(getRessourceType());
    }
    
 //       public void printAttraction() {
 //       System.out.print(getAttraction());
 //  }
    
    public String getRessourceType(){
      String res = "";
      switch (ressource){
          case 0 : res = "00";
                   break;
          case 1 : res = "r1";
                   break;                   
          case 2 : res = "r2";
                   break;   
          case 3 : res = "r3";
                   break;  
          default : res="error";
                   break;
      }
        return res;
    }
    
    public boolean estVideDeRessources(){
        return (this.ressource == 0);
    }   
    
    public int getRessource(){
        return this.ressource;
    }
    
    public void setRessource(int type){
        this.ressource = type;
    }

    void increaseQtePheromone() {
        QtePheromones++;
    }
     void decreaseQtePheromone() throws Exception {
         if (QtePheromones > 0){
        QtePheromones--;
         }
         else{
           throw new Exception("une pheromone qui netait pas presente a disparu...");    
         }
    }   

}
